package diamondServer.businesslogic.resource.loader;

import java.io.File;
import java.net.URL;

import diamondServer.businesslogic.resource.Resource;
import diamondServer.resources.MessageFake;
import diamondServer.resources.ServiceFake;



/*
 * The goal is to test whether reloading works properly in the 
 * {@ URLResourceLoader}. 
 * The Main method is loading an {@ MessageFake} and a {@ ServiceFake} and
 * executing the service. All these stuff it do in infinite loop. So you can
 * check the changes that happened when you are changing the code of 
 * the MessageFake class at the time that the iterations of a loop go forward.
 */
public class LoaderManualTest
{
	public static void main(String[] args)
		throws Exception
	{
		File f = new File("../tests/bin" +File.separator);	
		URL url = f.toURI().toURL();
		ResourceLoader rcl;

		while(true){
			rcl = new URLResourceLoader(/*url*/);
			Resource resource = 
				rcl.load(MessageFake.class.getName(), 
						ServiceFake.class.getName());
			
			resource.getService().provide( resource.getMessage() );
			
			// Change MessageFake class now, and check if the console message
			// is changed.
			Thread.sleep(10000);
		}	
	}
}
